<!DOCTYPE html>
<html>
<head>
    <title>{$user_login} - 个人中心</title>
    <meta name="keywords" content=""/>
    <meta name="description" content="">
    <include file="public@head"/>
    <style>
        .control-label {
            font-weight: bold;
            float: left;
            width: 70px;
        }
    </style>
</head>
<body class="body-white" id="top">
<include file="public@nav" />
<div class="container tc-main">
    <div class="row">
        <div class="col-md-3">
            <include file="public@usernav" />
        </div>
        <div class="col-md-9">
            <div class="tabs">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#one" data-toggle="tab"><i class="fa fa-home"></i> 作品评分</a></li>
                    <li><a href="{:cmf_url('portal/works/my_review')}" ><i class="fa fa-home"></i> 我的评分</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="one">
                        <br>
                        <form action="{:url('portal/works/review')}" method="post">
                            <div class="form-group">
                                <label for="contest">赛事</label>
                                <input type="text" class="form-control" id="contest"  value="{$contest.title|default=''}" disabled />
                                <input type="hidden" name="contest_id" value="{$contest.id|default=''}">
                            </div>
                            <div class="form-group">
                                <label for="category">赛事分类</label>
                                <select class="form-control" id="category" name="contest_category">
                                    <option value="0">请选择赛事分类</option>
                                    <if condition="isset($categories)">
                                        <foreach name="categories" item="voo">
                                            <if condition="$param.contest_category eq $voo.category_id">
                                                <option value="{$voo.category_id}" selected>{$voo.name}</option>
                                                <else/>
                                                <option value="{$voo.category_id}">{$voo.name}</option>
                                            </if>
                                            <!--                                        <option value="{$voo.category_id}">{$voo.name}</option>-->
                                        </foreach>
                                    </if>
                                </select>
                            </div>
                            <div class="form-group">
                                <button class="btn btn-primary">查询</button>
                                <a href="{:cmf_url('portal/works/review')}" class="btn btn-default">重置</a>
                            </div>
                            <div class="form-group" style="margin-top: 50px;">
                                <label>查看作品</label>
                                <table class="table table-striped">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>选手姓名</th>
                                            <th>赛事类别</th>
                                            <th>评委评分</th>
                                            <th>查看作品</th>
                                            <th>打分</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <if condition="!empty($works)">
                                        <foreach name="works" index="key" item="vo">
                                            <tr>
                                                <td>{$key}</td>
                                                <td>
                                                    <if condition="empty($vo.user_nickname)">
                                                        匿名
                                                        <else/>
                                                        {$vo.user_nickname}
                                                    </if>
                                                </td>
                                                <td>{$vo.c_name}</td>
                                                <td>
                                                    <if condition="!empty($vo.s_score)">
                                                        {$vo.s_score}分
                                                    </if>
                                                </td>
                                                <td>
                                                    <a href="{:cmf_url('portal/works/index',array('id'=>$vo['id']))}"
                                                       target="_blank">{$vo.title}</a>
                                                </td>
                                                <td>
                                                    <if condition="$review_str eq 1">
                                                        <a class="btn btn-xs btn-warning" id="score" onclick="reviewScore({$vo['id']});">打分</a>
                                                        <else/>
                                                        <span>已过期</span>
                                                    </if>
                                                </td>
                                            </tr>
                                        </foreach>
                                    </if>
                                    </tbody>
                                </table>
                                <ul class="pagination">{$page|default=''}</ul>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<include file="public@footer" />
<!-- /container -->
<include file="public@scripts" />
</body>
<script src="__STATIC__/js/admin.js"></script>
<script>
    function reviewScore($id) {
        openIframeLayer("{:url('Works/reviewWindow')}?id=" + $id, '请输入分数', {
            area: ['600px', '300px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var works = iframeWin.confirm();
                console.log(works);
                if (works.score.length == 0) {
                    layer.msg('请输入分数');
                    return;
                }
                $.ajax({
                    url: 'reviewPost',
                    type: 'post',
                    data: works,
                    dataType: 'JSON',
                    success: function (data) {
                        if (data.code == '1') {
                            noty({
                                text: data.msg,
                                type: 'success',
                                layout: 'topCenter',
                                modal: true,
                                timeout: 800,
                                callback: {
                                    afterClose: function () {
                                        if (data.url) {
                                            //返回带跳转地址
                                            window.location.href = data.url;
                                        } else {
                                            //刷新当前页
                                            reloadPage(window);
                                        }
                                    }
                                }
                            }).show();

                        } else if (data.code == '0') {
                            //art.dialog.alert(data.info);
                            //alert(data.info);//暂时处理方案
                            // art.dialog({
                            //     content: data.msg,
                            //     icon: 'warning',
                            //     ok: function () {
                            //         this.title(data.msg);
                            //         return true;
                            //     }
                            // });
                            noty({
                                text: data.msg,
                                type: 'error',
                                layout: 'topCenter',
                                modal: true,
                                timeout: 2000,
                            }).show();
                        }
                    }
                });
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>
</html>